Add TempFile and TempDirectory utilities#11
Conversation
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/ede74fd2-7b74-4470-bcfb-01606d5fc956 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/ede74fd2-7b74-4470-bcfb-01606d5fc956 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds disposable helpers for managing temp-file and temp-directory lifetimes in PowerKit, with accompanying tests to validate basic creation/cleanup behavior.
Changes:
- Introduces
TempFileandTempDirectorydisposable wrappers underPowerKit/. - Adds xUnit test coverage for temp file/directory creation and disposal.
- Implements directory materialization on create and recursive cleanup on dispose.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| PowerKit/TempFile.cs | Adds TempFile wrapper + factory method for generating a temp .tmp path and deleting it on dispose. |
| PowerKit/TempDirectory.cs | Adds TempDirectory wrapper + factory method that creates a unique temp directory and deletes it on dispose. |
| PowerKit.Tests/TempFileTests.cs | Adds tests for TempFile create/dispose behavior. |
| PowerKit.Tests/TempDirectoryTests.cs | Adds tests for TempDirectory create/dispose behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…Dispose_AlreadyDeleted_Test Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/ed7674be-23ff-4044-a7a9-f1a4f6aee3a7 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
|
@copilot if there are of our own tests that could benefit from TempFile/TempDirectory, apply the necessary changes |
After reviewing all existing test files, none of them create or manage real temp files/directories on disk — they all use in-memory alternatives ( |
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/6e27b26e-7cd9-4f27-938c-fab7e11f558e Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/53e634ef-afe6-456c-af5f-eb0891854da6 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…try loop in Create Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/c02e964b-3b92-4d67-b1d6-196fcef9031d Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
|
@copilot please fix failing test |
… resolve naming collision with Path property Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/3d364d09-b7bd-4e37-ade5-27b94d7e91a3 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Fixed in a9c01eb. The simplification of |
Adds
TempFileandTempDirectory—IDisposablewrappers that create uniquely-named resources under the system temp path and delete them on disposal.PowerKit/TempFile.cs— partial class;Create()generates a GUID-based.tmppath underPath.GetTempPath()and creates the file viaFile.Create;Dispose()deletes it (idempotent —File.Deletedoes not throw when the file is absent)PowerKit/TempDirectory.cs— same pattern;Create()generates and materializes a unique subdirectory;Dispose()recursively deletes it, suppressingDirectoryNotFoundExceptionModeled after the CliWrap test utilities of the same name, adapted for general-purpose library use.